﻿Ext.define('app.prm.synth.SynthList', {
    extend: 'Ext.panel.Panel',
    border: true,
    tbar: [],
    record: {},
    bodyStyle: 'padding:5px',
    initComponent: function () {
        var me = this;
        me.items = [me.getSynths()];
        me.tbar = [
            {
                text: '编辑工艺路线',
                bind: {
                    hidden: '{!hasSynthEdit}'
                },
                icon: '/Content/images/edit.gif',
                handler: function ()
                {
                    var win = Ext.create("app.prm.synth.CreateOrEdit", { title: '编辑工艺路线', SynthId: me.record.id });
                    win.on("savesuccess", function () {
                        me.fireEvent("editsuccess");
                        win.close();
                    });
                    win.show();
                }
            },
            {
                text: '删除工艺路线',
                bind: {
                    hidden: '{!hasSynthDelete}'
                },
                icon: '/Content/images/delete.gif',
                handler: function ()
                {
                    App.AjaxDelete('/api/services/app/synthesis/remove?synthId=' + me.record.id, function ()
                    {
                        me.fireEvent("removesuccess");
                    });
                }
            }
        ];
        me.callParent();
    },
    getSynths: function () {
        if (!this.basic) {
            this.basic = new Ext.Panel(
            {
                border: false,
                items: [
                    {
                        xtype: 'panel',
                        border: false,
                        style: 'padding:5px',
                        html: '<span style="font-family:应用字体;color:#004080;font-size:12pt;font-weight:bold;">工艺名称：' + this.record.synthName + '</span>'
                    },
                    {
                        xtype: 'panel',
                        img: this.record.imageBase,
                        listeners: {
                            afterrender: function () { 
                                showImg(this.getId(), this.img, 10, 'middle');
                            }
                        },
                        border: false
                    },
                    {
                        xtype: 'panel',
                        border: false,
                        style: 'padding:5px',
                        html: '<span>工艺备注：' + this.record.remark + '</span>'
                    }
                ]
            });
        }
        return this.basic;
    }
})